package com.kamistoat.reactortest2;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = {RuntimeException.class})
    @ResponseBody
    public HashMap<String, Object> process_1(HttpServletResponse httpServletResponse, RuntimeException runtimeException) {
        httpServletResponse.setStatus(500);
        HashMap<String, Object> res = new HashMap<>();
        res.put("exp", runtimeException);
        return res;
    }
}
